const { defineConfig } = require('@vue/cli-service')
const os = require('os')
/**
 * 获取当前机器的ip地址
 */
function getIpAddress() {
  let ifaces = os.networkInterfaces()
  for (let dev in ifaces) {
    let iface = ifaces[dev]
    for (let i = 0; i < iface.length; i++) {
      let { family, address, internal } = iface[i]
      if (family === 'IPv4' && address !== '127.0.0.1' && !internal) {
        return address
      }
    }
  }
}
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: process.env.NODE_ENV === 'development' ? '/' : '/admin',
  devServer: {
    host: getIpAddress(),
    hot: false,
    open: true,
    // https: true,
    proxy: {
      '/api': {
        // target: 'http://192.168.1.9:9998',
        target: 'http://192.168.1.24:9998',
        // target: 'http://192.168.1.8:9998',
        // target: 'http://10.0.0.2:9998',
        // target: 'https://sw.hczwfu.cn:9998',
        changOrigin: true,
        pathRewrite: {
          '^/api': '',
        },
      },
    },
  },
})
